<template>
  <div class="new-product-box">
    <Header />
    <div class="nav-box">
      <img src="@/assets/newProduct/nav.jpg">
    </div>
    <div class="content-box">
      <div class="title">
        <p>PRE-SALE OF NEW PRODUCT</p>
        <i>新品预售</i>
      </div>
      <div class="flex list-box jc-sa" >
        <div  class="list-item" v-loading="loading" v-for="item in list" :key="item">
          <h3>{{item.name}}</h3>
         <div class="grid-content"> <div class="info-content"><span >{{item.subTitle}}</span></div></div>
          <div class="flex jc-sb">
            <div>
              <el-button type="danger" round @click="getDetail(item.id)">立即预定</el-button>
            </div>
            <img :src="item.pic|nopic">
          </div>
        </div>
      </div>
    </div>
    <Footer />
  </div>
</template>
<script>
import Header from "@/components/Header.vue";
import Footer from "@/components/Footer.vue";
export default {
  components: {
    Header,
    Footer
  },
  data(){
      return {
          list:[],
          loading:true,
      }
  },
  created(){
      this.productList();
  },
  methods:{
    productList(){
        let _this = this;
        this.$http.post('/home/productlist',{
            "brandId":null,"pageNum":1,"pageSize":10,"publishStatus":1,"verifyStatus":1,
            "productCategoryId":null,"newStatus":1,"shopType":"2"
        }).then(function (response) {
            _this.list = response.data.list;
            _this.total = response.data.total;
            _this.loading = false;
        })
    },
    getDetail(id) {
      this.$http.get("/product/updateInfo/" + id).then((response) => {
        console.log(id,response)
        response.data.buyNum = 1;
        this.$router.push({ path: "/confirmOrder", query: response.data });
      }); 
    }
  }
}
</script>

<style lang="scss" scoped>
.nav-box {
  img {
    width: 100%;
  }
}
.title {
  margin: 40px 0 0;
  p {
    font-size: 28px;
    font-style: italic;
    color: #fa6163;
  }
  i {
    font-size: 28px;
    color: #333233;
  }
}
.list-box {
  flex-wrap: wrap;
  margin-bottom: 50px;
}
.grid-content{
  width: 165px;
}
.grid-content .info-content {
  width: 100%; /*根据自己项目进行定义宽度*/
  overflow: hidden; /*设置超出的部分进行影藏*/
  text-overflow: ellipsis; /*设置超出部分使用省略号*/
  white-space: nowrap; /*设置为单行*/
}
.list-item {
  width: 520px;
  height: 320px;
  background-color: #ffffff;
  border-radius: 10px;
  text-align: left;
  padding-left: 40px;
  box-sizing: border-box;
  padding-top: 30px;
  margin-top: 50px;
  overflow: hidden;

  h3 {
    font-size: 24px;
    color: #2e2e2e;
    z-index: 9;
  }

  span {
    font-size: 16px;
    color: #9e9e9e;
    padding: 20px 0;
    line-height: 50px;
    z-index: 9;
  }

  img {
    width: 300px;
    height: 240px;
    transform: translate(-10px , -50px);
  }

}

/*手机端*/
@media (min-width: 320px) and (max-width: 800px) {
  .nav-box {
    img {
      height: 130px;
    }
  }

  .title {
    margin: 20px;
    p {
      font-size: 24px;
    }
    i {
      font-size: 20px;
    }
  }
  .list-box {
    .list-item {
      width: 94%;
      margin-top: 10px;
      padding-left: 16px;
      padding-top: 18px;
      height: 190px;
      h3 {
        font-size: 18px;
      }
      span {
        display: block;
        width: 160px;
        height: 60px;
        padding: 0;
        font-size: 14px;
        line-height: 28px;
      }
      img {
        width: 160px;
        height: 120px;
      }
      /deep/ .el-button {
        padding: 8px 10px;
      }
    }
  }
}
</style>